package auth

import (
	"game-simple/internal/framework/auth/controllers"
	"game-simple/internal/framework/auth/middleware"
	"game-simple/internal/framework/router"

	"github.com/gin-gonic/gin"
)

// Module 认证模块（包含认证和用户管理）
type Module struct {
	controller     *controllers.Controller
	userController *controllers.UserController
}

// NewModule 创建认证模块实例
func NewModule() *Module {
	return &Module{
		controller:     controllers.NewController(),
		userController: controllers.NewUserController(),
	}
}

// RegisterRoutes 注册认证和用户相关路由
func (m *Module) RegisterRoutes(r *gin.RouterGroup) {
	authMiddleware := middleware.Middleware()

	// 注册认证路由
	authGroup := r.Group("/auth")
	router.RegisterRoutes(authGroup, getAuthRoutes(m.controller), authMiddleware)

	// 注册用户路由
	usersGroup := r.Group("/users")
	router.RegisterRoutes(usersGroup, getUserRoutes(m.userController), authMiddleware)
}
